package com.stu.covid.business.service;

import com.stu.covid.business.entity.Clazz;
import com.stu.covid.business.mapper.ClazzMapper;
import com.stu.covid.business.utils.CodeMsg;
import com.stu.covid.business.utils.Result;
import com.stu.covid.business.utils.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClazzService {
    @Autowired
    private ClazzMapper clazzMapper;

    public Result<Clazz> clazzList(Clazz clazz) {
        List<Clazz> list = clazzMapper.list(clazz);
        Integer count = clazzMapper.count(clazz);
        return ResultFactory.bulid(CodeMsg.SUCCESS, count, list);
    }

    public void clazzAdd(Clazz clazz) {
        clazzMapper.insertSelective(clazz);
    }

    public void clazzUpdate(Clazz clazz) {
        clazzMapper.updateByPrimaryKeySelective(clazz);
    }

    public void clazzDel(Integer id) {
        clazzMapper.deleteByPrimaryKey(id);
    }

    public List<Clazz> all() {
        return clazzMapper.selectAll();
    }

    public Clazz selectById(Integer id) {
        return clazzMapper.selectByPrimaryKey(id);
    }
}
